const testArr = [1,2,8,63,58]

/**
 * 模拟高阶函数map
 * @param {} array 
 * @param {} fn 
 */
const map =(array,fn)=>{
  let results = []
  for(let val of array){
    results.push(fn(val))
  }
  return results
}

/**
 * 模拟高阶函数every
 * @param {} array 
 * @param {} fn 
 */
const every = (array,fn)=>{
  let result = true
  for(let val of array){
    if(!fn(val)){
      result = false
      break
    }
  }
  return result
}

/**
 * 模拟高阶函数some
 * @param {} array 
 * @param {} fn 
 */
const some = (array,fn)=>{
  let result = false
  for(let val of array){
    if(fn(val)){
      result = true
      break
    }
  }
  return result
}
const mapResult = map(testArr,(val)=>val*val)
console.log(mapResult)
const everyResult = every(testArr,(val)=>val>10)
console.log(everyResult)
const someResult = some(testArr,(val)=>val<10)
console.log(someResult)
